<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>活动详情</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="../../../static/images/favicon.ico" th:href="@{/images/favicon.ico}">
    <link rel="stylesheet" href="../../../static/plugin/layui/css/layui.css" th:href="@{/plugin/layui/css/layui.css}" media="all" />
    <link rel="stylesheet" href="../../../static/back_css/create_details.css" th:href="@{/back_css/create_details.css}" media="all">
</head>
<body>
<div id="main">
    <div class="content2">
        <div class="layui-tab activity_news">
            <ul class="layui-tab-title">
                <li class="layui-this">参与单位</li>
                <li>活动信息</li>
                <li>活动详情</li>
                <li>活动时间</li>
                <li>活动奖品</li>
                <li>获奖规则</li>
                <li th:if="${admin_id}==${ActivityDetails.getADMIN_ID()} or ${isSup}==1">活动设置</li>
                <li>活动二维码</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label">活动单位</label>
                            <div class="layui-input-block">
                                <input type="radio" name="DEPT_TYPE" lay-filter="DEPT_TYPE" value="0" title="仅本级单位组织" th:checked="${ActivityDetails.DEPT_TYPE==0}">
                                <input type="radio" name="DEPT_TYPE" lay-filter="DEPT_TYPE" value="1" title="与下级单位联合组织" th:checked="${ActivityDetails.DEPT_TYPE==1}">
                            </div>
                            <div class="activity_info" width="50%">
                                <br><span>参与单位：<span th:text="${ActivityDetails.DEPT_NAMES}">未知</span></span><br><br><br>
                            </div>
                            <div id="deptTree" class="layui-form-item" style="display: none;">
                                <label class="layui-form-label">单位选择</label>
                                <div class="layui-input-inline">
                                    <div id="deptTree_div" class="ztree"></div>
                                </div>
                            </div>
                            <button lay-submit class="layui-btn btn_right" lay-filter="SUBMIT_DEPT" 
                                th:if="${admin_id}==${ActivityDetails.getADMIN_ID()} or ${isSup}==1">确定</button>
                        </form>
                    </div>
                </div>
                
                <div class="layui-tab-item">
                    <button type="button" class="layui-btn layui-btn-warm layui-btn-radius layui-color" id="basic_info_edit"
                        th:if="${admin_id}==${ActivityDetails.getADMIN_ID()} or ${isSup}==1">编辑</button>
                    <h1 th:text="${ActivityDetails.ACTIVITY_NAME}">未知活动</h1>
                    <div class="layui-inline authorsub">
                        <span>发布人：<span th:text="${ActivityDetails.ADMIN_NAME}">admin</span></span>&nbsp;&nbsp;&nbsp;&nbsp;
                        <span>发布时间：<span th:text="${ActivityDetails.CREATE_TIME}">2025-0-01 00:00:00</span></span>
                    </div>
                    <div class="news_content">
                        <img src="../../images/face.jpg" th:src="${ActivityDetails.ACTIVITY_IMG}">
                    </div>
                    <div class="activity_info">
                        <br>
                        <span>活动形式：
                            <span th:switch="${ActivityDetails.ACTIVITY_WAY}">
                                <span th:case="0">线上</span>
                                <span th:case="1">线下</span>
                                <span th:case="2">线上+线下</span>
                                <span th:case="*">未知</span>
                            </span>
                        </span><br>
                        <span>活动主题：<span th:text="${ActivityDetails.ACTIVITY_TOPIC}">未知</span></span><br>
                        <span>主办单位：<span th:text="${ActivityDetails.ZBDW}">未知</span></span><br>
                        <span>承办单位：<span th:text="${ActivityDetails.CBDW}">未知</span></span><br>
                        <span>执行承办：<span th:text="${ActivityDetails.ZXCB}">未知</span></span><br>
                    </div>
                </div>

                <div class="layui-tab-item">
                    <button type="button" class="layui-btn layui-btn-warm layui-btn-radius layui-color" id="details_edit"
                        th:if="${admin_id}==${ActivityDetails.getADMIN_ID()} or ${isSup}==1">编辑</button>
                    <div class="news_content">
                        <div style="padding:20px;">
                            <input type="hidden" id="HTML" th:value="${ActivityDetails.ACTIVITY_DETAILS}">
                            <textarea placeholder="请输入活动简介" id="ACTIVITY_DETAIL" style="width: 100%;margin: 0;height: 100%">
                            </textarea>
                        </div>
                    </div>
                </div>

                <div class="layui-tab-item">
                    <button type="button" class="layui-btn layui-btn-warm layui-btn-radius layui-color1" id="date_edit"
                        th:if="${admin_id}==${ActivityDetails.getADMIN_ID()} or ${isSup}==1">编辑</button>
                    <div class="date_set" th:if="${ActivityDetails.STAGE_IS_OPEN}==0"><span
                            th:text="'起止时间：'+${ActivityDetails.STARTTIME}+'-'+${ActivityDetails.ENDTIME}"></span>
                    </div>
                    <div class="date_set" th:if="${ActivityDetails.STAGE_1ST_NAME}!=null"><span
                            th:text="${ActivityDetails.STAGE_1ST_NAME}+' ： '+${ActivityDetails.ST1_STARTTIME}+'——'+${ActivityDetails.ST1_ENDTIME}"></span>
                    </div>
                    <div class="date_set" th:if="${ActivityDetails.STAGE_2ND_NAME}!=null"><span
                            th:text="${ActivityDetails.STAGE_2ND_NAME}+' ： '+${ActivityDetails.ST2_STARTTIME}+'——'+${ActivityDetails.ST2_ENDTIME}"></span>
                    </div>
                    <div class="date_set" th:if="${ActivityDetails.STAGE_3RD_NAME}!=null"><span
                            th:text="${ActivityDetails.STAGE_3RD_NAME}+' ： '+${ActivityDetails.ST3_STARTTIME}+'——'+${ActivityDetails.ST3_ENDTIME}"></span>
                    </div>
                    <div class="date_set" th:if="${ActivityDetails.STAGE_4TH_NAME}!=null"><span
                            th:text="${ActivityDetails.STAGE_4TH_NAME}+' ： '+${ActivityDetails.ST4_STARTTIME}+'——'+${ActivityDetails.ST4_ENDTIME}"></span>
                    </div>
                    <div class="date_set_item">
                        <form class="layui-form" action="" method="get">
                            <h2>时间设置</h2>
                            <button type="button" id="updateTime" lay-filter="updateTime" lay-submit
                                class="layui-btn layui-btn-warm layui-btn-radius layui-bg-oranges">确定</button>
                            <button type="button" id="date_cancel"
                                class="layui-btn layui-btn-warm layui-btn-radius cancel_color">取消</button>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <div class="layui-input-inline date_border">
                                        <i class="layui-icon layui-icon-date"></i>
                                        <input type="text" name="start_date" lay-verify="datetime" id="global_start_time" placeholder="设置开始时间" 
                                            autocomplete="off" class="layui-input date" th:value="${ActivityDetails.STARTTIME}">
                                    </div>
                                    <div class="layui-input-inline date_border">
                                        <i class="layui-icon layui-icon-date"></i>
                                        <input type="text" name="end_date" lay-verify="datetime" id="global_end_time" placeholder="设置结束时间"
                                            autocomplete="off" class="layui-input date" th:value="${ActivityDetails.ENDTIME}">
                                    </div>
                                    <div class="layui-input-inline open_create1">
                                        <input type="checkbox" name="detail_time_open" lay-filter="detail_time_open" lay-skin="primary"
                                            title="开启详细时间设置">
                                    </div>
                                </div>
                                <div class="layui-inline add_time">
                                    <button class="layui-btn" id="edit_match_time_item">添加</button>
                                    <span class="prompt">最多添加4个时间段</span>
                                </div>
                                <div id="match_time_add">
                                </div>
                            </div>
                        </form>
                    </div>
                </div>

                <div class="layui-tab-item" id="price_count">
                    <div th:if="${admin_id}==${ActivityDetails.getADMIN_ID()}  or ${isSup}==1 ">
                        <button type="button" class="layui-btn layui-btn-warm layui-btn-radius layui-color" id="prize_edit">新增</button>
                    </div>
                    <div class="prize_set" th:each="prize:${prizeList}">
                        <span th:text="${prize.PRIZE_NAME}+':'+${prize.PRIZE_USERNUMBER}+'名    奖品：'+${prize.PRIZE_GOODS}">一等奖：2名&nbsp;&nbsp;&nbsp;&nbsp;奖品：铅笔盒一个&nbsp;&nbsp;&nbsp;&nbsp;</span>
                        <a class="showimg1" th:data-img_url="${prize.PRIZE_GOODS_IMG}">图片</a>
                        <input type="hidden" class="prizeId" th:value="${prize.getPRIZE_ID()}"/>
                        <button  class="layui-btn layui-btn-xs layui-btn-danger delete_prize_btn" style="margin-left: 20px" th:if="${admin_id}==${ActivityDetails.getADMIN_ID()}  or ${isSup}==1 ">删除</button>
                    </div>
                    <div class="prize_set_item">
                        <form class="layui-form" action="" method="get">
                            <div class="layui-inline prize_add_content">
                                <div class="layui-input-inline add_prize">
                                    <button class="layui-btn" id="edit_prize_item">添加</button>
                                    <button type="button" id="prizeUpdate" lay-filter="prizeUpdate" lay-submit class="layui-btn layui-btn-warm layui-btn-radius layui-bg-oranges">确定</button>
                                    <button type="button" id="btn_cancel" class="layui-btn layui-btn-warm layui-btn-radius cancel_color">取消</button>
                                </div>
                            </div>
                            <span style="color:red;">注意：奖项名称，人数，奖品为必填项！</span>
                            <div id="prize_name_add"></div>
                        </form>
                    </div>
                </div>

                <div class="layui-tab-item" id="price_rules_count">
                    <div th:if="${admin_id}==${ActivityDetails.getADMIN_ID()}  or ${isSup}==1 ">
                        <button type="button" class="layui-btn layui-btn-warm layui-btn-radius layui-color"
                            id="prize_rules_edit">修改</button>
                    </div>
                    <div class="prize_set" th:if="${ActivityDetails.getPRIZE_RULE()}!=''">
                        <span th:text="${ActivityDetails.getPRIZE_RULE()}"></span>
                    </div>
                </div>

                <div class="layui-tab-item container1" th:if="${admin_id}==${ActivityDetails.getADMIN_ID()} or ${isSup}==1">
                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">阅读测评设置</label>
                            <div class="layui-input-block">
                                <input type="radio" name="IS_OPEN_YDCP" value="1" title="开启" th:checked="${ActivityDetails.IS_OPEN_YDCP == 1}">
                                <input type="radio" name="IS_OPEN_YDCP" value="0" title="关闭" th:checked="${ActivityDetails.IS_OPEN_YDCP == 0}">
                                <button lay-submit class="layui-btn btn_right" lay-filter="IS_OPEN_YDCP">确定</button>
                            </div>
                        </form>
                    </div>

                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">测评次数</label>
                            <div class="layui-input-block">
                                <input type="number" id="YDCP_NUM" name="YDCP_NUM" th:value="${ActivityDetails.YDCP_NUM}">
                                <button lay-submit class="layui-btn btn_right" lay-filter="YDCP_NUM">确定</button>
                            </div>
                        </form>
                    </div>

                    <div class="layui-form_container">
                        <div class="layui-input-block" th:each="groupRule:${groupRuleList}">
                            <span th:text="${groupRule.GROUP_NAME}+'：最小年龄/等级L：'+${groupRule.MIN}+'，最大年龄/等级L：'+${groupRule.MAX}"></span>
                            <input type="hidden" class="groupRuleId" th:value="${groupRule.ID}" />
                            <button class="layui-btn layui-btn-xs layui-btn-danger delete_rule_btn" style="margin-left: 20px"
                                th:if="${admin_id}==${ActivityDetails.getADMIN_ID()}  or ${isSup}==1 ">删除</button>
                        </div>
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">分组归集规则</label>
                            <div class="layui-input-block">
                                <input type="radio" name="GROUP_RULE" lay-filter="GROUP_RULE" value="0" title="不开启" th:checked="${ActivityDetails.GROUP_RULE == 0}">
                                <input type="radio" name="GROUP_RULE" lay-filter="GROUP_RULE" value="1" title="开启" th:checked="${ActivityDetails.GROUP_RULE == 1}">
                            </div>
                            <div class="layui-input-block" id="ruleList">
                                <input type="radio" name="GROUP_RULE_TYPE" lay-filter="GROUP_RULE_TYPE" value="1" title="按年龄分组" th:checked="${ActivityDetails.GROUP_RULE_TYPE == 1}">
                                <input type="radio" name="GROUP_RULE_TYPE" lay-filter="GROUP_RULE_TYPE" value="2" title="按阅读等级分组" th:checked="${ActivityDetails.GROUP_RULE_TYPE == 2}">
                                <button class="layui-btn layui-btn-primary" style="background-color: dodgerblue;color: #FFFFFF;" id="add_group_rule_item">添加</button>
                            </div>
                            <div id="group_rule_list" style="width: 1000px;">
                            </div>
                            <div class="layui-input-block">
                                <button lay-submit class="layui-btn btn_right" lay-filter="groupRuleUpdate">确定</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">年龄类型</label>
                            <div class="layui-input-block">
                                <input type="radio" name="AGE_TYPE" value="0" title="入学年龄" th:checked="${ActivityDetails.AGE_TYPE == 0}">
                                <input type="radio" name="AGE_TYPE" value="1" title="周岁年龄" th:checked="${ActivityDetails.AGE_TYPE == 1}">
                            </div>
                        </form>
                    </div>
                    <div class="layui-form_container" id="ageInfo">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">年龄范围</label>
                            <div class="layui-input-inline" style="display: flex; align-items: center; gap: 5px;margin-left: 450px;">
                                <input type="number" autocomplete="off" value="1" min="1" max="100" class="layui-input" name="MIN_AGE" id="MIN_AGE"
                                    style="width: 50px;" th:value="${ActivityDetails.MIN_AGE}">
                                <span>岁</span>
                                <span>----</span>
                                <input type="number" autocomplete="off" value="1" min="1" max="100" class="layui-input" name="MAX_AGE" id="MAX_AGE"
                                    style="width: 50px;" th:value="${ActivityDetails.MAX_AGE}">
                                <span>岁</span>
                            </div>
                        </form>
                    </div>

                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <input type="hidden" id="ORDER_RULE" name="ORDER_RULE" th:value="${ActivityDetails.ORDER_RULE}" />
                            <label class="layui-form-label" style="width: 170px;">活动排行规则</label>
                            <div class="layui-input-block">
                                <div class="layui-input-inline">
                                    <input type="checkbox" name="ORDER_JG" title="机构排行" value="1" lay-skin="primary">
                                    <input type="checkbox" name="ORDER_DQ" title="地区排行" value="1" lay-skin="primary">
                                    <input type="checkbox" name="ORDER_ZB" title="总榜排行" value="1" lay-skin="primary">
                                </div>
                                <button lay-submit class="layui-btn btn_right" lay-filter="ORDER_RULE">确定</button>
                            </div>
                        </form>
                    </div>

                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">投票阶段设置</label>
                            <div class="layui-input-block">
                                <input type="radio" name="IS_VOTE" value="0" title="未开始" th:checked="${ActivityDetails.IS_VOTE == 0}">
                                <input type="radio" name="IS_VOTE" value="1" title="开启投票" th:checked="${ActivityDetails.IS_VOTE == 1}">
                                <input type="radio" name="IS_VOTE" value="2" title="投票结束" th:checked="${ActivityDetails.IS_VOTE == 2}">
                                <button lay-submit class="layui-btn btn_right" lay-filter="is_vote">确定</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">报名截止时间</label>
                            <div class="layui-input-inline date_border">
                                <i class="layui-icon layui-icon-date"></i>
                                <input id="ACTIVITY_ENTRYTIME" type="text" name="ACTIVITY_ENTRYTIME" lay-verify="datetime" placeholder="设置报名截止时间"
                                    autocomplete="off" class="layui-input date" th:value="${ActivityDetails.ENTRYTIME}">
                            </div>
                            <button lay-submit class="layui-btn btn_right" lay-filter="ACTIVITY_ENTRYTIME">确定</button>
                        </form>
                    </div>
                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">报名设置</label>
                            <div class="layui-input-block">
                                <input type="radio" name="IS_SIGUP" value="0" title="正在进行报名" th:checked="${ActivityDetails.IS_SIGUP == 0}">
                                <input type="radio" name="IS_SIGUP" value="1" title="结束报名" th:checked="${ActivityDetails.IS_SIGUP == 1}">
                                <button lay-submit class="layui-btn btn_right" lay-filter="IS_SIGUP">确定</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">该活动限定每人上传作品数 </label>
                            <div class="layui-input-block">
                                <input type="number" id="WORKS_LIMIT_PERUSER" name="WORKS_LIMIT_PERUSER" th:value="${ActivityDetails.WORKS_LIMIT_PERUSER}">
                                <button lay-submit class="layui-btn btn_right" lay-filter="WORKS_LIMIT_PERUSER">确定</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">每天限制点赞次数</label>
                            <div class="layui-input-block">
                                <input type="number" id="VOTES_LIMIT_PERDAY" name="VOTES_LIMIT_PERDAY" th:value="${ActivityDetails.VOTES_LIMIT_PERDAY}">
                                <button lay-submit class="layui-btn btn_right" lay-filter="VOTES_LIMIT_PERDAY">确定</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">每天对同一作品点赞次数 </label>
                            <div class="layui-input-block">
                                <input type="number" id="VOTES_LIMIT_TOSINGLE_PERDAY" name="VOTES_LIMIT_TOSINGLE_PERDAY" th:value="${ActivityDetails.VOTES_LIMIT_TOSINGLE_PERDAY}">
                                <button lay-submit class="layui-btn btn_right" lay-filter="VOTES_LIMIT_TOSINGLE_PERDAY">确定</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">管理员是否提交作品</label>
                            <div class="layui-input-block">
                                <input type="radio" name="IS_SUBMIT" value="0" title="不提交" th:checked="${ActivityDetails.IS_SUBMIT == '0'}">
                                <input type="radio" name="IS_SUBMIT" value="1" title="提交" th:checked="${ActivityDetails.IS_SUBMIT == '1'}">
                                <button lay-submit class="layui-btn btn_right" lay-filter="IS_SUBMIT">确定</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">设置手机端展示作品阶段</label>
                            <div class="layui-input-block">
                                <div class="layui-input-inline">
                                <input type="radio" name="CURRENT_STAGE" value="0" title="审核通过阶段（审核通过之前）" th:checked="${ActivityDetails.CURRENT_STAGE == 0}">
                                <input type="radio" name="CURRENT_STAGE" value="1" title="提交阶段（各级管理员提交的作品）" th:checked="${ActivityDetails.CURRENT_STAGE == 1}"><br>
                                <input type="radio" name="CURRENT_STAGE" value="2" title="晋级作品（活动发布者晋级的作品）" th:checked="${ActivityDetails.CURRENT_STAGE == 2}">
                                </div>
                                <button lay-submit class="layui-btn btn_right" lay-filter="CURRENT_STAGE">确定</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <input type="hidden" id="WORK_TYPE" th:value="${ActivityDetails.WORK_TYPE}"/>
                            <label class="layui-form-label" style="width: 170px;">上传作品类型</label>
                            <div class="layui-input-block">
                                <div class="layui-input-inline">
                                <input type="checkbox" name="V_TYPE" title="视频作品" value="1" lay-skin="primary">
                                <input type="checkbox" name="A_TYPE" title="音频作品" value="1" lay-skin="primary">
                                <input type="checkbox" name="F_TYPE" title="范文朗读" value="1" lay-skin="primary">
                                <input type="checkbox" name="P_TYPE" title="图片作品" value="1" lay-skin="primary">
                                </div>
                                <button lay-submit class="layui-btn btn_right" lay-filter="WORK_TYPE">确定</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">各地区提交作品数量</label>
                            <div class="layui-input-block">
                                <input type="number" id="SUBMIT_WORK_NUMBER" name="SUBMIT_WORK_NUMBER" th:value="${ActivityDetails.SUBMIT_WORK_NUMBER}">
                                <button lay-submit class="layui-btn btn_right" lay-filter="SUBMIT_WORK_NUMBER">确定</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">手机端是否显示</label>
                            <div class="layui-input-block">
                                <input type="radio" name="DELETED" value="0" title="显示" th:checked="${ActivityDetails.DELETED == 0}">
                                <input type="radio" name="DELETED" value="1" title="不显示" th:checked="${ActivityDetails.DELETED == 1}">
                                <button lay-submit class="layui-btn btn_right" lay-filter="DELETED">确定</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">活动状态</label>
                            <div class="layui-input-block">
                                <input type="radio" name="ACTIVITY_STATE" value="0" title="未开始" th:checked="${ActivityDetails.ACTIVITY_STATE == '0'}">
                                <input type="radio" name="ACTIVITY_STATE" value="1" title="进行中" th:checked="${ActivityDetails.ACTIVITY_STATE == '1'}">
                                <input type="radio" name="ACTIVITY_STATE" value="2" title="已结束" th:checked="${ActivityDetails.ACTIVITY_STATE == '2'}">
                                <button lay-submit class="layui-btn btn_right" lay-filter="ACTIVITY_STATE">确定</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">手机端是否进入该活动</label>
                            <div class="layui-input-block">
                                <input type="radio" name="IS_IN" value="1" title="是" th:checked="${ActivityDetails.IS_IN == 1}">
                                <input type="radio" name="IS_IN" value="0" title="否" th:checked="${ActivityDetails.IS_IN == 0}">
                                <button lay-submit class="layui-btn btn_right" lay-filter="IS_IN">确定</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">手机端是否显示获奖名单</label>
                            <div class="layui-input-block">
                                <input type="radio" name="WINNERS" value="0" title="不显示" th:checked="${ActivityDetails.WINNERS == 0}">
                                <input type="radio" name="WINNERS" value="1" title="显示" th:checked="${ActivityDetails.WINNERS == 1}">
                                <button lay-submit class="layui-btn btn_right" lay-filter="WINNERS">确定</button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">该活动是否设置投票</label>
                            <div class="layui-input-block">
                                <input type="radio" name="IS_ROTE" value="1" title="不设置" th:checked="${ActivityDetails.IS_ROTE == 0}">
                                <input type="radio" name="IS_ROTE" value="0" title="设置" th:checked="${ActivityDetails.IS_ROTE == 1}">
                                <button lay-submit class="layui-btn btn_right" lay-filter="IS_ROTE">确定</button>
                            </div>
                        </form>
                    </div>

                    <div class="layui-form_container">
                        <form class="layui-form" action="" method="get">
                            <label class="layui-form-label" style="width: 170px;">是否显示评论</label>
                            <div class="layui-input-block">
                                <input type="radio" name="IS_SHOW_COMMENT" value="1" title="是" th:checked="${ActivityDetails.IS_SHOW_COMMENT == 1}">
                                <input type="radio" name="IS_SHOW_COMMENT" value="0" title="否" th:checked="${ActivityDetails.IS_SHOW_COMMENT == 0}">
                                <button lay-submit class="layui-btn btn_right" lay-filter="IS_SHOW_COMMENT">确定</button>
                            </div>
                        </form>
                    </div>
                </div>
                <div class="layui-tab-item">
                    <div class="news_content">
                        <img id="IMG_ACTIVITY_CODE" src="../../images/face.jpg" th:src="${ActivityDetails.ACTIVITY_CODE}" style="width: 300px;">
                    </div>
                    <!-- <button lay-submit class="layui-btn btn_right" lay-filter="GEN_ACTIVITY_CODE">重新生成</button> -->
                </div>
            </div>
        </div>
    </div>
</div>

<div class="edit_details basic_info">
    <form class="layui-form content1" action="" >
        <h2>编辑活动信息</h2>
        <div class="layui-form_content">
            <div class="layui-form-item">
                <label class="layui-form-label">活动标题</label>
                <div class="layui-input-block">
                    <input type="text" id="ACTIVITY_NAME" name="ACTIVITY_NAME" maxlength="60" lay-verify="title" autocomplete="off" th:value="${ActivityDetails.ACTIVITY_NAME}" placeholder="请输入活动标题（60字以内）"
                        class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">活动主题</label>
                <div class="layui-input-block">
                    <input type="text" name="ACTIVITY_TOPIC" id="ACTIVITY_TOPIC" autocomplete="off" th:value="${ActivityDetails.ACTIVITY_TOPIC}" placeholder="请输入活动主题"
                        class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">活动封面</label>
                <div class="layui-input-block jacket_btn">
                    <input name="ACTIVITY_IMG" class="upload_img" id="ACTIVITY_IMG" th:value="${ActivityDetails.ACTIVITY_IMG}" type="hidden">
                    <div class="upload_jacket_img" th:style="'content:url('+${ActivityDetails.ACTIVITY_IMG}+')'">
                    </div>
                    <span class="prompt">请上传尺寸为750*360px的PNG、JPG、GIF图片，大小&lt;10M</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">活动形式</label>
                <div class="layui-input-block">
                    <input type="radio" name="ACTIVITY_WAY" lay-filter="ACTIVITY_WAY" value="0" title="线上" th:checked="${ActivityDetails.ACTIVITY_WAY == 0}">
                    <input type="radio" name="ACTIVITY_WAY" lay-filter="ACTIVITY_WAY" value="1" title="线下" th:checked="${ActivityDetails.ACTIVITY_WAY == 1}">
                    <input type="radio" name="ACTIVITY_WAY" lay-filter="ACTIVITY_WAY" value="2" title="线上+线下" th:checked="${ActivityDetails.ACTIVITY_WAY == 2}">
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">主办单位</label>
                <div class="layui-input-block">
                    <input type="text" name="ZBDW" id="ZBDW" lay-verify="title" autocomplete="off" placeholder="请输入主办单位" th:value="${ActivityDetails.ZBDW}"
                        class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">承办单位</label>
                <div class="layui-input-block">
                    <input type="text" name="CBDW" id="CBDW" lay-verify="title" autocomplete="off" placeholder="请输入承办单位" th:value="${ActivityDetails.CBDW}"
                        class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">执行承办</label>
                <div class="layui-input-block">
                    <input type="text" name="ZXCB" id="ZXCB" lay-verify="title" autocomplete="off" placeholder="请输入执行承办" th:value="${ActivityDetails.ZXCB}"
                        class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form_bottom">
            <button type="button" id="basic_cancel" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-grays">取消</button>
            <button type="button" id="basic_confirm" lay-filter="updateBasic" lay-submit class="layui-btn layui-btn-warm layui-btn-radius layui-bg-oranges">确定</button>
        </div>
    </form>
</div>

<div class="edit_details details">
    <form class="layui-form content1" action="">
        <h2>编辑活动详情</h2>
        <div class="layui-form_content">
            <div class="layui-form-item">
                <label class="layui-form-label">活动详情</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入活动简介" id="ACTIVITY_DETAILS" name="ACTIVITY_DETAILS"
                        class="layui-textarea"></textarea>
                </div>
            </div>
        </div>
        <div class="layui-form_bottom">
            <button type="button" id="details_cancel"
                class="layui-btn layui-btn-warm layui-btn-radius layui-bg-grays">取消</button>
            <button type="button" id="details_confirm" lay-filter="updateDetails" lay-submit
                class="layui-btn layui-btn-warm layui-btn-radius layui-bg-oranges">确定</button>
        </div>
    </form>
</div>

<div class="edit_details rules">
    <form class="layui-form content1" action="" >
        <h2>修改获奖规则</h2>
        <div class="layui-form_content">
            <div class="layui-form-item">
                <label class="layui-form-label">获奖规则</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入获奖规则" id="PRIZE_RULE" name="PRIZE_RULE" th:text="${ActivityDetails.getPRIZE_RULE()}" class="layui-textarea"></textarea>
                </div>
            </div>
        </div>
        <div class="layui-form_bottom">
            <button type="button" id="close" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-grays">取消</button>
            <button type="button" id="commit" lay-filter="commit" lay-submit class="layui-btn layui-btn-warm layui-btn-radius layui-bg-oranges">确定</button>
        </div>
    </form>
</div>

<datalist class="race_stage" id="match_name_list" name="matchset">
    <option value="初赛"></option>
    <option value="复赛"></option>
    <option value="决赛"></option>
</datalist>
<datalist class="race_stage" id="match_way_list" name="matchway">
    <option value="线上"></option>
    <option value="线下"></option>
    <option value="线上+线下"></option>
</datalist>

<script type="text/html" id="match_date_item">
    <form class="layui-form-item match">
        <div class="match_name">
            <input class="layui-input" type="text" name="STAGE_NAME" list="match_name_list" placeholder="名称">
        </div>
        <div class="match_name">
            <input class="layui-input" type="text" name="STAGE_WAY" list="match_way_list" placeholder="方式">
        </div>
        <div class="layui-inline">
            <label class="layui-form-label time_set">时间设置</label>
            <div class="layui-input-inline date_border">
                <i class="layui-icon layui-icon-date"></i>
                <input type="text" name="match_start_date" lay-verify="datetime" placeholder="2025-04-01" autocomplete="off"
                    class="layui-input date">
            </div>
            <label class="layui-form-label date_set1">至</label>
            <div class="layui-input-inline date_border">
                <i class="layui-icon layui-icon-date"></i>
                <input type="text" name="match_end_date" lay-verify="datetime" placeholder="2025-04-01" autocomplete="off"
                    class="layui-input date ">
            </div>
        </div>
        <button type="button" class="layui-btn matchtime_del">删除</button>
    </form>
</script>

<script type="text/html" id="prize_name_item">
    <form class="layui-form-item prize_item">
        <div class="layui-inline">
            <label class="layui-form-label time_set">奖项名称</label>
            <div class="layui-input-inline date_border">
                <input type="text" autocomplete="off" class="layui-input" list="3" placeholder="奖项名称" name="PRIZE_NAME">
                <datalist class="race_stage" id="3">
                    <option value="一等奖"></option>
                    <option value="二等奖"></option>
                    <option value="三等奖"></option>
                </datalist>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label people_num">人数</label>
            <div class="layui-input-inline date_border">
                <input type="number" autocomplete="off" value="1" min="1" class="layui-input" name="PRIZE_USERNUMBER">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label people_num">奖品</label>
            <div class="layui-input-inline date_border">
                <input type="text" autocomplete="off"  placeholder="奖品名称" class="layui-input" name="PRIZE_GOODS">
            </div>
        </div>
        <button class="layui-btn prizename_del" >删除</button>
        <div class="layui-form-item">
            <label class="layui-form-label">奖品封面</label>
            <div class="layui-input-block jacket_btn1">
                <input type="hidden"  class="upload_img"  name="PRIZE_GOODS_IMG">
                <div class="upload_jacket_img1">
                </div>
                <span class="prompt">请上传尺寸为750*360px的PNG、JPG、GIF图片，大小不超过10M</span>
            </div>
        </div>
    </form>
</script>
<script type="text/html" id="group_rule_item">
    <form class="layui-form-item rule_item" style="width: 1000px;">
        <div class="layui-inline">
            <label class="layui-form-label">分组名称</label>
            <div class="layui-input-inline">
                <input type="text" autocomplete="off" placeholder="分组名称" name="GROUP_NAME" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">年龄范围</label>
            <div class="layui-input-inline" style="display: flex; align-items: center; gap: 5px;">
                <input type="number" autocomplete="off" value="1" min="1" max="100" class="layui-input" name="MIN" style="width: 50px;">
                <span>岁</span>
                <span>----</span>
                <input type="number" autocomplete="off" value="1" min="1" max="100" class="layui-input" name="MAX" style="width: 50px;">
                <span>岁</span>
            </div>
        </div>
        <button class="layui-btn rule_del" style="background-color: crimson;">删除</button>
    </form>
</script>

<script type="text/html" id="group_rule_item_level">
    <form class="layui-form-item rule_item_level" style="width: 1000px;">
        <div class="layui-inline">
            <label class="layui-form-label">分组名称</label>
            <div class="layui-input-inline">
                <input type="text" autocomplete="off" placeholder="分组名称" name="GROUP_NAME" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">等级范围</label>
            <div class="layui-input-inline" style="display: flex; align-items: center; gap: 5px;">
                <span>L</span>
                <input type="number" autocomplete="off" value="0" min="0" max="12" class="layui-input" name="MIN" style="width: 50px;">
                <span>----</span>
                <span>L</span>
                <input type="number" autocomplete="off" value="0" min="0" max="12" class="layui-input" name="MAX" style="width: 50px;">
            </div>
        </div>
        <button class="layui-btn rule_del_level" style="background-color: crimson;">删除</button>
    </form>
</script>
<script type="text/javascript" src="../../../static/plugin/layui/layui.js" th:src="@{/plugin/layui/layui.js}"></script>
<script type="text/javascript">
    var laydate;
    var $;
    layui.use(['form', "laydate","jquery","element",'upload','layer',"layedit", "tree"], function () {
        var form = layui.form,
            layer = layui.layer;
        var element = layui.element;
        var layedit = layui.layedit;
        var tree = layui.tree;
        $ = layui.jquery;
        laydate = layui.laydate;

        var html = $("#HTML").val();
        $("#ACTIVITY_DETAIL").html(html);
        $("#ACTIVITY_DETAILS").html(html);

        layedit.build('ACTIVITY_DETAIL', {//建立编辑器
            tool: [ //清除链接
            ],
            contenteditable:false
        });
        $(document).ready(function () {
            $("#ACTIVITY_DETAIL").next().find('iframe').contents().find('body').prop("contenteditable",false);
        })

        $(window).on('resize', function() {
            // iframe窗口自适应
            var $content = $("#ACTIVITY_DETAIL");
            $content.height($(this).height() - 125);
            $content.next().find('iframe').each(function() {
                $(this).height($content.height());
            });
        }).resize();

        htmlss = layedit.build('ACTIVITY_DETAILS', {//建立编辑器
            tool: ['strong' //加粗
                ,'italic' //斜体
                ,'underline' //下划线
                ,'del' //删除线
                ,'left' //左对齐
                ,'center' //居中对齐
                ,'right' //右对齐
                ,'link' //超链接
                ,'unlink' //清除链接
                ,'face'
            ]
        });

        function initDeptTree() {
            $.ajax({
                url: '/district/tree',
                type: 'POST',
                success: function (data) {
                    const treeData = convertToTree(data);
                    console.log("组织树：", treeData);
                    tree.render({
                        id: 'deptTree',
                        elem: '#deptTree_div',
                        data: treeData,
                        showCheckbox: true
                    });
                },
                error: function (reason) {
                    layer.msg("网络错误！")
                }
            })
        }
        function convertToTree(data) {
            data.forEach(item => {
                item.title = item.district_NAME; // 显式设置 title 字段
            });
            var map = {};
            data.forEach(item => {
                map[item.id] = item;
            });
            var roots = [];
            data.forEach(item => {
                if (item.parent_ID === 1) {
                    roots.push(item);
                } else {
                    const parent = map[item.parent_ID];
                    if (!parent.children) {
                        parent.children = [];
                    }
                    parent.children.push(item);
                }
            });
            return roots;
        }

        function getCheckedId(data) {
            var id = "";
            $.each(data, function (index, item) {
                if (id != "") {
                    id = id + "," + item.id;
                } else {
                    id = item.id;
                }
                if (item.children != null) {
                    var i = getCheckedId(item.children);
                    if (i != "") {
                        id = id + "," + i;
                    }
                }
            });
            return id;
        }
        function getCheckedName(data) {
            var name = "";
            $.each(data, function (index, item) {
                if (name != "") {
                    name = name + "," + item.title;
                } else {
                    name = item.title;
                }
                if (item.children != null) {
                    var i = getCheckedName(item.children);
                    if (i != "") {
                        name = name + "," + i;
                    }
                }
            });
            return name;
        }

        form.on("radio(DEPT_TYPE)", function (data) {
            if (data.value == "0") {
                $("#deptTree").css("display", "none");
            } else {
                $("#deptTree").css("display", "inline-block");
            }
            initDeptTree();
        });


        $(".upload_jacket_img").on("click", function (a, b) {
            var that=this;
            var ipt = document.createElement("input")
            ipt.type = "file";
            ipt.multiple = false;
            ipt.accept="image/*"
            ipt.onchange = function (ev) {
                console.log(ipt.files);
                if (ipt.files.length > 0) {
                    var formdata = new FormData();
                    formdata.append("file", ipt.files[0]);
                    formdata.append("dir","activity");
                    $.ajax({
                        url: "/operate/uploadImg",
                        data: formdata,
                        type: "post",
                        async: false,
                        processData: false,
                        contentType: false,
                        success: function (result) {
                            console.log("result:", result);
                            var path = result;
                            $(that).css("content", "url(" + path + ")");
                            $(that).siblings("input.upload_img").val(path);
                        },
                        error: function (ret) {
                            layer.msg("网络错误！")
                        }
                    })
                }
                ipt = null;
            }
            ipt.click();
        });
        $(".date").each(function(index,item){
            laydate.render({
                elem: item,
                type: 'datetime'
            });
        })

        var WORK_TYPE = $("#WORK_TYPE").val();
        if(WORK_TYPE==1){
            $("input[name^='V_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
        }else if(WORK_TYPE==2){
            $("input[name^='A_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
        }else if(WORK_TYPE==3){
            $("input[name^='V_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
            $("input[name^='A_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
        }else if(WORK_TYPE==4){
            $("input[name^='F_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
        }else if(WORK_TYPE==5){
            $("input[name^='V_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
            $("input[name^='F_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
        }else if(WORK_TYPE==6){
            $("input[name^='A_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
            $("input[name^='F_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
        }else if(WORK_TYPE==7){
            $("input[name^='V_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
            $("input[name^='A_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
            $("input[name^='F_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
        }else if(WORK_TYPE==8){
            $("input[name^='P_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
        }else if(WORK_TYPE==9){
            $("input[name^='V_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
            $("input[name^='P_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
        }else if(WORK_TYPE==10){
            $("input[name^='A_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
            $("input[name^='P_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
        }else if(WORK_TYPE==11){
            $("input[name^='V_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
            $("input[name^='A_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
            $("input[name^='P_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
        }else if(WORK_TYPE==12){
            $("input[name^='F_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
            $("input[name^='P_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
        }else if(WORK_TYPE==13){
            $("input[name^='V_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
            $("input[name^='F_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
            $("input[name^='P_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
        }else if(WORK_TYPE==14){
            $("input[name^='A_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
            $("input[name^='F_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
            $("input[name^='P_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
        }else if(WORK_TYPE==15){
            $("input[name^='V_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
            $("input[name^='A_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
            $("input[name^='F_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
            $("input[name^='P_TYPE']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
        }

        var ORDER_RULE = $("#ORDER_RULE").val();
        if(ORDER_RULE==1){
            $("input[name^='ORDER_JG']").each(function () {
                $(this).prop("checked",true);
                form.render();
            })
        }else if(ORDER_RULE==2){
            $("input[name^='ORDER_DQ']").each(function () {
                $(this).prop("checked", true);
                form.render();
            })
        }else if(ORDER_RULE==3){
            $("input[name^='ORDER_ZB']").each(function () {
                $(this).prop("checked", true);
                form.render();
            })
        }else if(ORDER_RULE==4){
            $("input[name^='ORDER_JG']").each(function () {
                $(this).prop("checked", true);
                form.render();
            })
            $("input[name^='ORDER_DQ']").each(function () {
                $(this).prop("checked", true);
                form.render();
            })
        }else if (ORDER_RULE == 5) {
            $("input[name^='ORDER_JG']").each(function () {
                $(this).prop("checked", true);
                form.render();
            })
            $("input[name^='ORDER_ZB']").each(function () {
                $(this).prop("checked", true);
                form.render();
            })
        }else if (ORDER_RULE == 6) {
            $("input[name^='ORDER_DQ']").each(function () {
                $(this).prop("checked", true);
                form.render();
            })
            $("input[name^='ORDER_ZB']").each(function () {
                $(this).prop("checked", true);
                form.render();
            })
        }else if (ORDER_RULE == 7) {
            $("input[name^='ORDER_JG']").each(function () {
                $(this).prop("checked", true);
                form.render();
            })
            $("input[name^='ORDER_DQ']").each(function () {
                $(this).prop("checked", true);
                form.render();
            })
            $("input[name^='ORDER_ZB']").each(function () {
                $(this).prop("checked", true);
                form.render();
            })
        }

        var DEPT_TYPE = $('input[name="DEPT_TYPE"]:checked').val();
        if (DEPT_TYPE == "0") {
            $("#deptTree").css("display", "none");
            initDeptTree();
        } else {
            $("#deptTree").css("display", "inline-block");
            initDeptTree();
        }

        var GROUP_RULE = $('input[name="GROUP_RULE"]:checked').val();
        if (GROUP_RULE == "0") {
            $("#ageInfo").css("display", "inline-block");
            $("#ruleList").css("display", "none");
            $("#group_rule_list").css("display", "none");
        } else {
            $("#ageInfo").css("display", "none");
            $("#ruleList").css("display", "inline-block");
            $("#group_rule_list").css("display", "inline-block");
        }

        form.on("radio(GROUP_RULE)", function (data) {
            if (data.value == "0") {
                $("#ageInfo").css("display", "inline-block");
                $("#ruleList").css("display", "none");
                $("#group_rule_list").css("display", "none");
            } else {
                $("#ageInfo").css("display", "none");
                $("#ruleList").css("display", "inline-block");
                $("#group_rule_list").css("display", "inline-block");
            }
        });
        form.on("radio(GROUP_RULE_TYPE)", function (data) {
            $("#group_rule_list").empty();
        });

        $("#add_group_rule_item").click(function (event) {//添加奖项
            var groupRuleType = $('input[name="GROUP_RULE_TYPE"]:checked').val();
            if (groupRuleType == "1") {
                $("#group_rule_list").append($("#group_rule_item").html());
            } else {
                $("#group_rule_list").append($("#group_rule_item_level").html());
            }
            return false;
        });
        $("#group_rule_list").on("click", ".rule_del", function () {
            if ($(this).parent(".rule_item")) {
                $(this).parent(".rule_item").remove();
            }
            return false;
        })
        $("#group_rule_list").on("click", ".rule_del_level", function () {
            if ($(this).parent(".rule_item_level")) {
                $(this).parent(".rule_item_level").remove();
            }
            return false;
        })

        form.on("submit(SUBMIT_DEPT)", function (data) {
            var obj = {};
            var deptType = $('input[name="DEPT_TYPE"]:checked').val();
            obj["DEPT_TYPE"] = deptType;
            if (deptType == "0") {
                obj["DEPT_IDS"] = "";
                obj["DEPT_NAMES"] = "";
            }else{
                if (tree.index == 0) {
                    obj["DEPT_IDS"] = "";
                    obj["DEPT_NAMES"] = "";
                } else {
                    var checkedNodes = tree.getChecked('deptTree');
                    var nodeIds = getCheckedId(checkedNodes);
                    var nodeNames = getCheckedName(checkedNodes);
                    obj["DEPT_IDS"] = nodeIds;
                    obj["DEPT_NAMES"] = nodeNames;
                }
            }
            $.ajax({
                url: '/deptUpdate',
                async: false,
                type: "POST",
                data: JSON.stringify(obj),
                contentType: "application/json",
                success: function (data) {
                    if (data) {
                        layer.msg("提交成功！")
                        window.location.href = '/getActivityDetails';
                    }
                }
            })
            return false;
        })


        form.on("submit(updateBasic)",function(data){
            var obj = {};
            obj["ACTIVITY_NAME"]= $("#ACTIVITY_NAME").val();
            obj["ACTIVITY_IMG"] = $("#ACTIVITY_IMG").val();
            obj["ACTIVITY_TOPIC"] = $("#ACTIVITY_TOPIC").val();
            obj["ACTIVITY_WAY"] = $('input[name="ACTIVITY_WAY"]:checked').val();//活动形式
            obj["ZBDW"] = $("#ZBDW").val();
            obj["CBDW"] = $("#CBDW").val();
            obj["ZXCB"] = $("#ZXCB").val();
            layer.load(1);
            $.ajax({
                url: '/updateActivityById',
                type: 'POST',
                data: obj,
                success: function (result) {
                    window.location.href='/getActivityDetails';
                },
                error:function(reason){
                    layer.msg("网络错误");
                }
            })
            return false;
        })
        form.on("submit(updateDetails)", function (data) {
            var obj = {};
            var html = layedit.getContent(htmlss);
            obj["ACTIVITY_DETAILS"] = html;
            layer.load(1);
            $.ajax({
                url: '/updateActivityDetailsById',
                type: 'POST',
                data: obj,
                success: function (result) {
                    window.location.href = '/getActivityDetails';
                },
                error: function (reason) {
                    layer.msg("网络错误");
                }
            })
            return false;
        })
        form.on("submit(updateTime)", function (data) {
            var formData = new FormData();
            var ACTIVITY_STARTTIME = $("#global_start_time").val();//开始时间
            var ACTIVITY_ENDTIME = $("#global_end_time").val();//开始时间
            formData.append("STARTTIME", ACTIVITY_STARTTIME);
            formData.append("ENDTIME", ACTIVITY_ENDTIME);
            var time_info = [];
            $("#match_time_add").children("form").each(function (index, item) {
                time_info.push($(item).serializeObject())
            });
            if (time_info.length != 0) {
                formData.append("STAGE_IS_OPEN", 1);
                formData.append("STAGE_1ST_NAME", time_info[0].STAGE_NAME);
                formData.append("STAGE_1ST_WAY", time_info[0].STAGE_WAY);
                formData.append("ST1_STARTTIME", time_info[0].match_start_date);
                formData.append("ST1_ENDTIME", time_info[0].match_end_date);
                formData.append("STAGE_1ST_WIN", 0);
                if (time_info[1] != null) {
                    formData.append("STAGE_2ND_NAME", time_info[1].STAGE_NAME);
                    formData.append("STAGE_2ND_WAY", time_info[1].STAGE_WAY);
                    formData.append("ST2_STARTTIME", time_info[1].match_start_date);
                    formData.append("ST2_ENDTIME", time_info[1].match_end_date);
                    formData.append("STAGE_2ND_WIN", 0);
                }
                if (time_info[2] != null) {
                    formData.append("STAGE_3RD_NAME", time_info[2].STAGE_NAME);
                    formData.append("STAGE_3RD_WAY", time_info[2].STAGE_WAY);
                    formData.append("ST3_STARTTIME", time_info[2].match_start_date);
                    formData.append("ST3_ENDTIME", time_info[2].match_end_date);
                    formData.append("STAGE_3RD_WIN", 0);
                }
                if (time_info[3] != null) {
                    formData.append("STAGE_4TH_NAME", time_info[3].STAGE_NAME);
                    formData.append("STAGE_4TH_WAY", time_info[3].STAGE_WAY);
                    formData.append("ST4_STARTTIME", time_info[3].match_start_date);
                    formData.append("ST4_ENDTIME", time_info[3].match_end_date);
                    formData.append("STAGE_4TH_WIN", 0);
                }
            } else {
                formData.append("STAGE_IS_OPEN", 0);
            }
            $.ajax({
                url: '/updateTime',
                type: 'post',
                cache: false,
                data: formData,
                processData: false,
                contentType: false,
                success: function (result) {
                    window.location.href = '/getActivityDetails';
                }
            })
            return false;
        })
        form.on("submit(commit)",function(data){//修改获奖规则
            if(data.field.PRIZE_RULE.length>2000){
                alert("您已超过字数最大限制！");
                return;
            }
            setTimeout(function(){
                $.ajax({
                    url:"/updateActivityRules",
                    async:false,
                    type: 'POST',
                    cache: false,
                    data:data.field,
                    success:function (data) {
                        window.location.href='/getActivityDetails';
                    }
                })
            },1000);
            return false;
        })
        $.fn.serializeObject = function () {
            var o = {};
            var a = this.serializeArray();
            $.each(a, function () {
                if (o[this.name]) {
                    if (!o[this.name].push) {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } else {
                    o[this.name] = this.value || '';
                }
            });
            return o;
        }
        form.on("submit(prizeUpdate)",function(data){
            var prize_info = [];
            var is_empty=false;
            $("#prize_name_add").children("form").each(function (index, item) {
                var tmp=$(item).serializeObject();
                prize_info.push(tmp)
                if(!tmp.PRIZE_NAME||!tmp.PRIZE_USERNUMBER||!tmp.PRIZE_GOODS)is_empty=true;
            });
            if(is_empty){
                layer.msg("奖项名称，人数，奖品为必填项！");
                return false;
            }

            if(prize_info.length==0){
                console.log(prize_info);
                layer.msg("请添加新的奖项！");
                return false;
            }

            $.ajax({
                url: '/updatePrize',
                type: 'post',
                data: JSON.stringify(prize_info),
                contentType: "application/json",
                dataType:"json",
                success: function (result) {
                    console.log(result);
                    window.location.href='/getActivityDetails';
                },
                error:function (res) {
                    layer.msg("网络错误！");
                }
            })
            return false;
        })

        form.on("submit(IS_OPEN_YDCP)", function (data) {
            $.ajax({
                url: '/IS_OPEN_YDCP',
                async: false,
                type: "POST",
                data: {
                    IS_OPEN_YDCP: data.field.IS_OPEN_YDCP
                },
                success: function (data) {
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        })
        form.on("submit(YDCP_NUM)", function (data) {
            $.ajax({
                url: '/YDCP_NUM',
                async: false,
                type: "POST",
                data: {
                    YDCP_NUM: data.field.YDCP_NUM
                },
                success: function (data) {
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        })
        form.on("submit(ORDER_RULE)", function (data) {
            var ORDER_JG = $('input[name="ORDER_JG"]:checked').val();
            if (undefined == ORDER_JG) {
                ORDER_JG = 0;
            }
            var ORDER_DQ = $('input[name="ORDER_DQ"]:checked').val();
            if (undefined == ORDER_DQ) {
                ORDER_DQ = 0;
            }
            var ORDER_ZB = $('input[name="ORDER_ZB"]:checked').val();
            if (undefined == ORDER_ZB) {
                ORDER_ZB = 0;
            }
            var order_rule = 0;
            if (ORDER_JG == 1 && ORDER_DQ == 0 && ORDER_ZB == 0) {//机构
                order_rule = 1
            } else if (ORDER_JG == 0 && ORDER_DQ == 1 && ORDER_ZB == 0) {//地区
                order_rule = 2;
            } else if (ORDER_JG == 0 && ORDER_DQ == 0 && ORDER_ZB == 1) {//总榜
                order_rule = 3;
            } else if (ORDER_JG == 1 && ORDER_DQ == 1 && ORDER_ZB == 0) {//机构、地区
                order_rule = 4;
            } else if (ORDER_JG == 1 && ORDER_DQ == 0 && ORDER_ZB == 1) {//机构、总榜
                order_rule = 5;
            } else if (ORDER_JG == 0 && ORDER_DQ == 1 && ORDER_ZB == 1) {//地区、总榜
                order_rule = 6;
            } else if (ORDER_JG == 1 && ORDER_DQ == 1 && ORDER_ZB == 1) {//机构、地区、总榜
                order_rule = 7;
            }
            $.ajax({
                url: '/ORDER_RULE',
                async: false,
                type: "POST",
                data: {
                    ORDER_RULE: order_rule
                },
                success: function (data) {
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        })
        
        form.on("submit(groupRuleUpdate)", function (data) {
            var obj = {};
            obj["GROUP_RULE"] = $('input[name="GROUP_RULE"]:checked').val();
            obj["GROUP_RULE_TYPE"] = $('input[name="GROUP_RULE_TYPE"]:checked').val();
            var group_rule_info = [];
            $("#group_rule_list").children("form").each(function (index, item) {
                var tmp = $(item).serializeObject();
                group_rule_info.push(tmp);
            });
            obj.groupRuleInfos = group_rule_info;
            obj["AGE_TYPE"] = $('input[name="AGE_TYPE"]:checked').val();
            obj["MIN_AGE"] = $("#MIN_AGE").val();
            obj["MAX_AGE"] = $("#MAX_AGE").val();

            $.ajax({//进行审核提交
                url: '/groupRuleUpdate',
                async: false,
                type: "POST",
                data: JSON.stringify(obj),
                contentType: "application/json",
                success: function (data) {
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        })
        //设置投票
        form.on('submit(is_vote)', function (data) {
            $.ajax({//进行审核提交
                url: '/IS_VOTE',
                async: false,
                type: "POST",
                data: {
                    IS_VOTE: data.field.IS_VOTE
                },
                success: function (data) {
                    // console.log(data)
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });
        //该活动是否手机端显示
        form.on('submit(DELETED)', function (data) {
            $.ajax({//进行审核提交
                url: '/DELETED',
                async: false,
                type: "POST",
                data: {
                    DELETED: data.field.DELETED
                },
                success: function (data) {
                    // console.log(data)
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });
        //上传作品数
        form.on('submit(WORKS_LIMIT_PERUSER)', function (data) {
            $.ajax({//进行审核提交
                url: '/WORKS_LIMIT_PERUSER',
                async: false,
                type: "POST",
                data: {
                    WORKS_LIMIT_PERUSER: data.field.WORKS_LIMIT_PERUSER
                },
                success: function (data) {
                    // console.log(data)
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });
        //每天点赞次数
        form.on('submit(VOTES_LIMIT_PERDAY)', function (data) {
            //alert(data.field.VOTES_LIMIT_PERDAY);
            $.ajax({//进行审核提交
                url: '/VOTES_LIMIT_PERDAY',
                async: false,
                type: "POST",
                data: {
                    VOTES_LIMIT_PERDAY: data.field.VOTES_LIMIT_PERDAY
                },
                success: function (data) {
                    // console.log(data)
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });
        //每天对同一作品点赞次数
        form.on('submit(VOTES_LIMIT_TOSINGLE_PERDAY)', function (data) {
            $.ajax({//进行审核提交
                url: '/VOTES_LIMIT_TOSINGLE_PERDAY',
                async: false,
                type: "POST",
                data: {
                    VOTES_LIMIT_TOSINGLE_PERDAY: data.field.VOTES_LIMIT_TOSINGLE_PERDAY
                },
                success: function (data) {
                    // console.log(data)
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });
        //管理员是否提交作品
        form.on('submit(IS_SUBMIT)', function (data) {
            $.ajax({//进行审核提交
                url: '/IS_SUBMIT',
                async: false,
                type: "POST",
                data: {
                    IS_SUBMIT: data.field.IS_SUBMIT
                },
                success: function (data) {
                    // console.log(data)
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });
        //手机端显示
        form.on('submit(CURRENT_STAGE)', function (data) {
            $.ajax({//进行审核提交
                url: '/CURRENT_STAGE',
                async: false,
                type: "POST",
                data: {
                    CURRENT_STAGE: data.field.CURRENT_STAGE
                },
                success: function (data) {
                    // console.log(data)
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });
        //手机端是否进入该活动
        form.on('submit(IS_IN)', function (data) {
            $.ajax({//进行审核提交
                url: '/IS_IN',
                async: false,
                type: "POST",
                data: {
                    IS_IN: data.field.IS_IN
                },
                success: function (data) {
                    // console.log(data)
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });

        form.on('submit(IS_SHOW_COMMENT)', function (data) {
            $.ajax({//进行审核提交
                url: '/IS_SHOW_COMMENT',
                async: false,
                type: "POST",
                data: {
                    IS_SHOW_COMMENT: data.field.IS_SHOW_COMMENT
                },
                success: function (data) {
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });
        
        //手机端是否进入该活动
        form.on('submit(WINNERS)', function (data) {
            $.ajax({//进行审核提交
                url: '/WINNERS',
                async: false,
                type: "POST",
                data: {
                    WINNERS: data.field.WINNERS
                },
                success: function (data) {
                    // console.log(data)
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });

        //手机端是否进入该活动
        form.on('submit(IS_ROTE)', function (data) {
            $.ajax({//进行审核提交
                url: '/IS_ROTE',
                async: false,
                type: "POST",
                data: {
                    IS_ROTE: data.field.IS_ROTE
                },
                success: function (data) {
                    // console.log(data)
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });

        form.on('submit(GEN_ACTIVITY_CODE)', function (data) {
            $.ajax({//进行审核提交
                url: '/GEN_ACTIVITY_CODE',
                async: false,
                type: "POST",
                success: function (data) {
                    if (data) {
                        console.log(data);
                        $("#IMG_ACTIVITY_CODE").attr("src", data);
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });
        
        //活动状态
        form.on('submit(ACTIVITY_STATE)', function (data) {
            $.ajax({//进行审核提交
                url: '/ACTIVITY_STATE',
                async: false,
                type: "POST",
                data: {
                    ACTIVITY_STATE: data.field.ACTIVITY_STATE
                },
                success: function (data) {
                    // console.log(data)
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });
        //上传作品类型
        form.on('submit(WORK_TYPE)', function (data) {
            //console.log(data);
            $.ajax({//进行审核提交
                url: '/WORK_TYPE',
                async: false,
                type: "POST",
                data: {
                    V_TYPE: data.field.V_TYPE,
                    A_TYPE: data.field.A_TYPE,
                    F_TYPE: data.field.F_TYPE,
                    P_TYPE: data.field.P_TYPE
                },
                success: function (data) {
                    // console.log(data)
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });
        
        //报名限制
        form.on('submit(ACTIVITY_ENTRYTIME)', function (data) {
            $.ajax({//进行审核提交
                url: '/setEntryTime',
                async: false,
                type: "POST",
                data: {
                    ENTRYTIME: data.field.ACTIVITY_ENTRYTIME
                },
                success: function (data) {
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });
        //报名限制
        form.on('submit(IS_SIGUP)', function (data) {
            $.ajax({//进行审核提交
                url: '/IS_SIGUP',
                async: false,
                type: "POST",
                data: {
                    IS_SIGUP: data.field.IS_SIGUP
                },
                success: function (data) {
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });
        //提交作品数量
        form.on('submit(SUBMIT_WORK_NUMBER)', function (data) {
            $.ajax({//进行审核提交
                url: '/SUBMIT_WORK_NUMBER',
                async: false,
                type: "POST",
                data: {
                    SUBMIT_WORK_NUMBER: data.field.SUBMIT_WORK_NUMBER
                },
                success: function (data) {
                    // console.log(data)
                    if (data) {
                        layer.msg("提交成功！")
                    }
                }
            })
            return false;
        });

        form.on("checkbox(detail_time_open)",function(obj){
            //获取表单元素 对应的渲染元素
            if(obj.elem.checked){
                if ($("#global_start_time").val() == "" || $("#global_end_time").val() == "") {
                    layer.msg("请先设置开始和结束时间")
                    obj.elem.checked = false;
                    obj.othis.removeClass("layui-form-checked");
                    return;
                }
                $(".add_time").css("display","inline-block");
            }else{
                $(".add_time").css("display","none");
                $("#match_time_add").empty();
            }
        })

        $("#edit_match_time_item").click(function(event){
            var s = $("#match_time_add").children(".match").length;
            if (s < 4) {
                //设置第一项
                $("#match_time_add").append($("#match_date_item").html());
                s++;
                //使时间指示器生效
                $("#match_time_add").children().last().find(".date").each(function (index, item) {
                    laydate.render({
                        elem: item,
                        type: 'datetime',
                        //点击日期、清空、现在、确定均会触发。回调返回三个参数，分别代表：生成的值、日期时间对象、结束的日期时间对象
                        done: function (value, date, endDate) {
                        }
                    });
                })
            } else {
                layer.msg("最多支持添加4个时间段！")
            }
            $(".matchtime_del").on("click",function () {
                if ($(this).parent(".match")) {
                    $(this).parent(".match").remove();
                }
                return false;
            });
            return false;
        });

        $("#prize_name_add").on("click",".prizename_del",function(event){
            if ($(this).parent(".prize_item")) {
                $(this).parent(".prize_item").remove();
            }
            return false;
        });
         $("#prize_name_add").on("click",".upload_jacket_img1",function(event){
             var that=this;
             var ipt = document.createElement("input")
             ipt.type = "file";
             ipt.multiple = false;
             ipt.accept="image/*"
             ipt.onchange = function (ev) {
                 console.log(ipt.files);
                 if (ipt.files.length > 0) {
                     var formdata = new FormData();
                     formdata.append("file", ipt.files[0]);
                     formdata.append("dir","prize");
                     $.ajax({
                         url: "/operate/uploadImg",
                         data: formdata,
                         type: "post",
                         async: false,
                         processData: false,
                         contentType: false,
                         success: function (result) {
                             console.log("result:", result);
                                var path = result;
                                $(that).css("content", "url(" + path + ")");
                                $(that).siblings("input.upload_img").val(path);
                         },
                         error: function (ret) {
                             layer.msg("网络错误！")
                         }
                     })
                 }
                 ipt = null;
             }
             ipt.click();

        });

        $("#edit_prize_item").click(function(event){
            $("#prize_name_add").append($("#prize_name_item").html());
            return false;
        });
        $(".showimg1").on("click",function () {
            var that=this;
            var img_url=$(this).data("img_url");
            layer.open({
                title:'',
                type: 4,
                content: ['<div class="img_alert" >\n' +
                '        <img  src="'+img_url+'" >\n' +
                '    </div>', that],
                shade:0,
                shadeClose:true,
                anim:0,
                tips: [1, '#0000'],
                time:2000
            })
        });
        $(".showimg2").on("click",function () {
            var that=this;
            layer.open({
                title:'',
                type: 4,
                content: [$("#prize_img2").html(), that],
                shade:0,
                shadeClose:true,
                anim:0,
                tips: [1, '#0000'],
                time:2000
            })
        });
        $(".showimg3").on("click",function () {
            var that=this;
            layer.open({
                title:'',
                type: 4,
                content: [$("#prize_img3").html(), that],
                shade:0,
                shadeClose:true,
                anim:0,
                tips: [1, '#0000'],
                time:2000
            })
        });

        $("#basic_info_edit").click(function () {
            $(".basic_info").css("display","block")
        });
        $("#basic_cancel").click(function () {
            $(".basic_info").css("display", "none")
        });

        $("#details_edit").click(function () {
            $(".details").css("display", "block")
        });
        $("#details_cancel").click(function () {
            $(".details").css("display", "none")
        });

        $("#date_edit").on("click", function () {
            $(".date_set_item").css("display", "block");
        });
        $("#date_cancel").on("click", function () {
            $(".date_set_item").css("display", "none");
        });

        $("#prize_rules_edit").click(function () {
            $(".rules").css("display","block")
        });
        $("#close").click(function () {
            $(".rules").css("display","none")
        });
        $("#prize_edit").on("click",function () {
            $(".prize_set_item").css("display","block");
        });
        $("#btn_cancel").on("click",function () {
            $("#prize_name_add").empty();
            $(".prize_set_item").css("display","none");
        });

        $(".delete_prize_btn").click(function () {
            var prizeId = $(this).siblings("input.prizeId").val()
            layer.confirm('你确定要删除吗？', function(index){
                $.ajax({//进行审核提交
                    url: '/deletePrize',
                    async: false,
                    type: "POST",
                    data: {
                        PrizeId: prizeId
                    },
                    success: function (data) {
                        layer.msg("删除成功！");
                        setTimeout(function(){
                            window.location.href='/getActivityDetails';
                        },500)
                    }
                })
            },function (index) {
                layer.close(index);
            });
        })

        $(".delete_rule_btn").click(function () {
            var groupRuleId = $(this).siblings("input.groupRuleId").val();
            layer.confirm('你确定要删除吗？', function (index) {
                $.ajax({//进行审核提交
                    url: '/deleteGroupRule',
                    async: false,
                    type: "POST",
                    data: {
                        groupRuleId: groupRuleId
                    },
                    success: function (data) {
                        layer.msg("删除成功！");
                        setTimeout(function () {
                            window.location.href = '/getActivityDetails';
                        }, 500)
                    }
                })
            }, function (index) {
                layer.close(index);
            });
        })

    })
</script>

</body>
</html>